<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
//images_type
//		1		product
//		2		category
//images_target
//		type	target
//		1		products_id
//		2		categories_id

//
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'base.item.class.php');

class ProductCategoryImageBase extends BaseItemBase {
	var $_target = 0;
	var $_type = 2;
	
	//constructor
	function ProductCategoryImageBase() {
		parent::BaseItemBase();
		
		$this->table = 'pp_products_images';
		$this->prefix = 'images_';
	}
	
	//setter/getter
	function setTargetType($target, $type = '0') {
		if( $target > 0 ) {
			$this->_target = $target;
		}
		if( $type > 0 ) {
			$this->_type = $type;
		}
	}
	
	//methods
	function _get_query_str_custom() {
		$query_str = "";
		if( $this->_target > 0 ) {
			$query_str .= " and " . $this->_pf('target') . " = '" . (int)$this->_target . "'";
		}
		if( $this->_type > 0 ) {
			$query_str .= " and " . $this->_pf('type') . " = '" . (int)$this->_type . "'";
		}
		
		return $query_str;
	}
}
//
?>